
import request from '@/utils/request'

const customerApi = {
    createCustomer: '/v1/customer/create', // 劳务创建客户
    queryUserCustomerList: '/v1/customer/my/list', // 获取用户所没有的客户列表（平台关联）
    queryCustomerList: '/v1/customer/info/page/list', // 获取客户信息分页列表
    deleteCustomer: '/v1/customer/delete/', // 删除客户信息
    getCustomerDetail: '/v1/customer/detail/', // 获取客户详情信息
    updateCustomerInfo: '/v1/customer/update', // 更新客户信息
    createCustomerBusiness: '/v1/customer/business/create', // 创建客户业务
    relationCustomer: '/v1/customer/relation/', // 关联平台客户
    queryCustomerBusinessList: '/v1/customer/business/service/list', // 获取客户业务列表
    updateCustomerBusinessState: '/v1/customer/business/state/change', // 修改客户业务状态
    updateCustomerBusinessRate: '/v1/customer/business/service/rate/update', // 修改客户业务费率
    getCustomerBusinessRateRecord: '/v1/customer/business/service/rate/update/record', // 获取修改费率记录
    getCustomerByCompany: '/v1/customer/by/companyId/', // 根据公司获取关联的客户列表
}

// 劳务创建客户
export function createCustomer (parameter) {
    return request({
        url: customerApi.createCustomer,
        method: 'post',
        headers: {
            'name':'createCustomer',
        },
        data: parameter
    })
}

// 获取当前用户所有客户列表
export function queryUserCustomerList (parameter) {
    return request({
        url: customerApi.queryUserCustomerList,
        method: 'get',
        headers: {
            'name':'queryUserCustomerList',
        },
        params: parameter
    })
}

// 获取客户分页列表信息
export function queryCustomerList (parameter) {
    return request({
        url: customerApi.queryCustomerList,
        method: 'get',
        headers: {
            'name':'queryCustomerList',
        },
        params: parameter
    })
}

// 删除客户信息
export function deleteCustomer (customerId) {
    return request({
        url: `${customerApi.deleteCustomer}${customerId}`,
        method: 'post',
        headers: {
            'name':'deleteCustomer',
        },
        data: {}
    })
}

// 获取客户详情信息
export function getCustomerDetail (parameter) {
    return request({
        url: `${customerApi.getCustomerDetail}${parameter}`,
        method: 'get',
        headers: {
            'name':'getCustomerDetail',
        },
        params: {}
    })
}

// 更新客户信息
export function updateCustomerInfo (parameter) {
    return request({
        url: customerApi.updateCustomerInfo,
        method: 'post',
        headers: {
            'name':'updateCustomerInfo',
        },
        data: parameter
    })
}

// 获取所有客户信息列表
export function queryAllCustomerList (parameter) {
    return request({
        url: customerApi.queryAllCustomerList,
        method: 'get',
        headers: {
            'name':'queryAllCustomerList',
        },
        params: parameter
    })
}

// 创建客户业务
export function createCustomerBusiness (parameter) {
    return request({
        url: customerApi.createCustomerBusiness,
        method: 'post',
        headers: {
            'name':'createCustomerBusiness',
        },
        data: parameter
    })
}

// 关联平台客户信息
export function relationCustomer (customerId) {
    return request({
        url: customerApi.relationCustomer + customerId,
        method: 'post',
        headers: {
            'name':'relationCustomer',
        },
        data: {}
    })
}

// 获取客户业务列表
export function queryCustomerBusinessList (parameter) {
    return request({
        url: customerApi.queryCustomerBusinessList,
        method: 'get',
        headers: {
            'name':'queryCustomerBusinessList',
        },
        params: parameter
    })
}

// 修改客户业务状态
export function updateCustomerBusinessState (parameter) {
    return request({
        url: customerApi.updateCustomerBusinessState,
        method: 'post',
        headers: {
            'name':'updateCustomerBusinessState',
        },
        data: parameter
    })
}

// 修改客户业务服务费率
export function updateCustomerBusinessRate (parameter) {
    return request({
        url: customerApi.updateCustomerBusinessRate,
        method: 'post',
        headers: {
            'name':'updateCustomerBusinessRate',
        },
        data: parameter
    })
}

// 获取客户业务费率修改记录
export function getCustomerBusinessRateRecord (parameter) {
    return request({
        url: customerApi.getCustomerBusinessRateRecord,
        method: 'post',
        headers: {
            'name':'getCustomerBusinessRateRecord',
        },
        data: parameter
    })
}

// 根据公司获取已关联的客户列表
export function getCustomerByCompany (companyId) {
    return request({
        url: customerApi.getCustomerByCompany + companyId,
        method: 'get',
        headers: {
            'name':'getCustomerByCompany',
        },
        params: {}
    })
}